voting_url.test.js ➔ ... ➔ ???   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 4
b 0
f 0
1
import VotingUrl from './voting_url'
2
const Url = require('url')
3
4
describe('a voting url', () => {
5
  const abaseUrl = 'http://domain.org'
6
  const anEventPoll = { 'id': '32' }
7
8
  const aVotingUrl = new VotingUrl(abaseUrl, anEventPoll)
9
10
  expect(aVotingUrl).toBeInstanceOf(VotingUrl)
11
12
  it('has base url and a voting poll', () => {
13
    expect(aVotingUrl.baseUrl).toBe(abaseUrl)
14
    expect(aVotingUrl.votingPoll).toBe(anEventPoll)
15
  })
16
17
  it('has a value equal to a valid voting url', () => {
18
    const actualUrl = Url.parse(aVotingUrl.value())
19
20
    expect(actualUrl.host).toBe(Url.parse(abaseUrl).host)
21
    expect(actualUrl.protocol).toBe(Url.parse(abaseUrl).protocol)
22
    expect(actualUrl.path).toBe('/voting/' + anEventPoll.id)
23
  })
24
25
  it('is not equal to a random url', () => {
26
    expect(aVotingUrl.equalsTo('http://www.wikipedia.org')).toBeFalsy()
27
  })
28
29
  it('is not equal to a random votingUrl', () => {
30
    const anotherVotingUrl = new VotingUrl('http://domain.org', { 'id': 33 })
31
    expect(aVotingUrl.equalsTo(anotherVotingUrl)).toBeFalsy()
32
  })
33
})
34